{-# OPTIONS -Wall #-}

module Demo01 where


import Majalan.Base
import Majalan.Base.Objects



data Orch = WG_BOWED_BAR | ZAKOUT | METRO
  deriving (Eq,Ord,Show)


instance CsOrch Orch where
  instNumber WG_BOWED_BAR = 1
  instNumber ZAKOUT       = 2
  instNumber METRO        = 100

-- Note - zakports not abstracted at present...

wgBowedBar :: Decimal -> Decimal -> Decimal -> EventFw uctx ()
wgBowedBar iamp ipch iconst = 
    let izakout = 1 in
    makeEventFw WG_BOWED_BAR () 2.0 (const [ VFloat iamp
                                           , VFloat ipch
                                           , VFloat iconst
                                           , VInt   izakout
                                           ])


metroClick :: Decimal -> EventFw uctx ()
metroClick idamp =                               
    makeEventFw METRO () 1.0 (const [ VFloat idamp ])


zakout :: Processor
zakout = 
    let izakin = 1 in makeProcessor ZAKOUT 2.0 [ VInt izakin ]


type MyCtx = ()

ctx_zero :: MyCtx
ctx_zero = ()

--
-- Note - is notation improved with having onset and duration 
-- split from event?
-- 
--
score01 :: ScoreObj
score01 = score default_timeline ctx_zero $ do 
    _   <- clickTrack 3 $ metroClick 0
    pt1 <- namedPart  "Bowed bar" $ eventList 0 $ do 
                { eventFw 0 $ wgBowedBar 0.90 130.813 0
                ; eventFw 2 $ wgBowedBar 0.90 146.832 0
                ; event 4 2 $ accTremolo 146.832 4 $ \pch -> wgBowedBar 0.9 pch 0
                ; event 6 2 $ trill 130.813 146.832 4 $ \pch -> wgBowedBar 0.9 pch 0
                ; event 8 2 $ decTremolo 146.832 4 $ \pch -> wgBowedBar 0.9 pch 0
                }
    bracket pt1 zakout
  




col_specs :: ColumnSpecs
col_specs = columnSpecs [ (WG_BOWED_BAR, cols_bowed_bar) 
                        , (ZAKOUT,       cols_zakout)
                        ]
  where             
    cols_bowed_bar  = [ defaultFormat "amp", defaultFormat "pch"
                      , defaultFormat "const", defaultFormat "zout" ]
    cols_zakout     = [ defaultFormat "zakin" ]





demo01 :: IO ()
demo01 = shellTest odac "orc/wgbowedbar.orc" $ renderScoreObj col_specs score01
    





--- Flarf...

-- Ideally we would like to change Zak ports without 
-- (significantly) changing scores, this implies that Zak ports 
-- should be stored in an env.

-- orch:
-- signalgen-inst
-- wah-wah-proc
-- no-effect proc

